package com.bjqg.bjqg01.bjqg.activity.longrange.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bjqg.bjqg01.bjqg.R;
import com.bjqg.bjqg01.bjqg.activity.longrange.bean.MultipleListBean;
import com.zhy.autolayout.AutoLinearLayout;

import java.util.List;

import butterknife.BindView;

/**
 * Created by bjqg01 on 2018/9/4.
 */

public class MutipleListAdapter extends RecyclerView.Adapter<MutipleListAdapter.MyViewHolder> {


    List<MultipleListBean> list;
    Context context;


    private onItemClickListener onItemClickListener;

    public interface onItemClickListener {
        void onItem(int position);
    }

    public void setOnItemClickListener(onItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public MutipleListAdapter(List<MultipleListBean> list, Context context) {
        this.list = list;
        this.context = context;
    }


    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(context).inflate(R.layout.item_content, parent, false);

        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        holder.tvYwt.setText(list.get(position).getYwtnumber());//预委托
        holder.tvWsdjzt.setText(list.get(position).getWsdjzt());//网上登记状态

        holder.tvYpzt.setText(list.get(position).getYpzt());//样品状态

        holder.tvZsbh.setText(list.get(position).getZsbh());//正式编号

        holder.tvSyzt.setText(list.get(position).getSyzt());//试验状态

        holder.tvSpzt.setText(list.get(position).getSpzt());//审批状态

        holder.tvBgffzt.setText(list.get(position).getBgffzt());//报告发放状态

        holder.llfather.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null) {
                    onItemClickListener.onItem(position);
                }
            }
        });

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        TextView tvYwt;
        AutoLinearLayout llYwt;
        View vYwt;
        TextView tvWsdjzt;
        AutoLinearLayout llWsdjzt;
        View vWsdjzt;
        TextView tvYpzt;
        AutoLinearLayout llYpzt;
        View vYpzt;
        TextView tvZsbh;
        AutoLinearLayout llZsbh;
        View vZsbh;
        TextView tvSyzt;
        AutoLinearLayout llSyzt;
        View vSyzt;
        TextView tvSpzt;
        AutoLinearLayout llSpzt;
        View vSpzt;
        TextView tvBgffzt;
        AutoLinearLayout llBgffzt;
        View vBgffzt;
        AutoLinearLayout llfather;

        public MyViewHolder(View itemView) {
            super(itemView);
            llfather = (AutoLinearLayout) itemView.findViewById(R.id.ll_father);
            tvYwt = (TextView) itemView.findViewById(R.id.tv_ywt);
            llYwt = (AutoLinearLayout) itemView.findViewById(R.id.ll_ywt);
            vYwt = (View) itemView.findViewById(R.id.v_ywt);
            tvWsdjzt = (TextView) itemView.findViewById(R.id.tv_wsdjzt);
            llWsdjzt = (AutoLinearLayout) itemView.findViewById(R.id.ll_wsdjzt);
            vWsdjzt = (View) itemView.findViewById(R.id.v_wsdjzt);
            tvYpzt = (TextView) itemView.findViewById(R.id.tv_ypzt);
            llYpzt = (AutoLinearLayout) itemView.findViewById(R.id.ll_ypzt);
            vYpzt = (View) itemView.findViewById(R.id.v_ypzt);
            tvZsbh = (TextView) itemView.findViewById(R.id.tv_zsbh);
            llZsbh = (AutoLinearLayout) itemView.findViewById(R.id.ll_zsbh);
            vZsbh = (View) itemView.findViewById(R.id.v_zsbh);
            tvSyzt = (TextView) itemView.findViewById(R.id.tv_syzt);
            llSyzt = (AutoLinearLayout) itemView.findViewById(R.id.ll_syzt);
            vSyzt = (View) itemView.findViewById(R.id.v_syzt);
            tvSpzt = (TextView) itemView.findViewById(R.id.tv_spzt);
            llSpzt = (AutoLinearLayout) itemView.findViewById(R.id.ll_spzt);
            vSpzt = (View) itemView.findViewById(R.id.v_spzt);
            tvBgffzt = (TextView) itemView.findViewById(R.id.tv_bgffzt);
            llBgffzt = (AutoLinearLayout) itemView.findViewById(R.id.ll_bgffzt);
            vBgffzt = (View) itemView.findViewById(R.id.v_bgffzt);
        }
    }
}
